package com.zhaotianhao.check.itemserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhaotianhao.check.itemserver.entity.Item;
import com.zhaotianhao.check.itemserver.entity.ItemVO;
import com.zhaotianhao.check.itemserver.mapper.ItemMapper;
import com.zhaotianhao.check.itemserver.service.IItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Z-7
 * @since 2022-03-29
 */
@Service
public class ItemServiceImpl extends ServiceImpl<ItemMapper, Item> implements IItemService {

    /**
     * 查询
     *
     * @param itemVO
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<Item> getPageInfo(ItemVO itemVO, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        if (!StringUtils.hasText(itemVO.getCondition())) {
            return new PageInfo<>(list());
        }
        QueryWrapper<Item> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("item_coding",itemVO.getCondition())
                .or().like("item_name",itemVO.getCondition());
        return new PageInfo<>(list(queryWrapper));
    }
}
